// File generated with Tower of Babel version: 5.3-beta on 09/05/17
var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var power;
(function (power) {
    var _B = BABYLON;
    var _M = _B.Matrix.FromValues;
    var _Q = _B.Quaternion;
    var _V = _B.Vector3;
    function CONTIG(array, offset, begin, end) {
        for(var i = 0, len = 1 + end - begin; i < len; i++) {
            array[offset + i] = begin + i;
        }
    }
    function REPEAT(array, offset, nRepeats, val) {
        for(var i = 0; i < nRepeats; i++) {
            array[offset + i] = val;
        }
    }
    var _sceneTransitionName;
    var _overriddenMillis;
    var _overriddenSound;
    var _options;

    function initScene(scene, resourcesRootDir, positionOffset, sceneTransitionName, overriddenMillis, overriddenSound, options) {
        if (!resourcesRootDir) { resourcesRootDir = "./"; }
        function MOVE(mesh, positionOffset) {
            mesh.position.addInPlace(positionOffset);
            if (mesh.isWorldMatrixFrozen) mesh.freezeWorldMatrix();
        }

        _sceneTransitionName = sceneTransitionName;
        _overriddenMillis    = overriddenMillis;
        _overriddenSound     = overriddenSound;
        _options             = options;

        scene.autoClear = true;
        scene.clearColor    = new _B.Color3(.0509,.0509,.0509);
        scene.ambientColor  = new _B.Color3(0,0,0);
        scene.gravity = new _V(0,-9.81,0);

        // define materials before meshes
        defineMaterials(scene, resourcesRootDir);

        // instance all root meshes
        var mesh;
        mesh = new powerShelf("powerShelf", scene);
        if (positionOffset) MOVE(mesh, positionOffset);

        if (sceneTransitionName && matLoaded) {
            QI.SceneTransition.perform(sceneTransitionName, waitingMeshes, overriddenMillis, overriddenSound, options);
        }
    }
    power.initScene = initScene;

    var waitingMeshes = [];
    var pendingTextures = 0;
    var texLoadStart = 0;
    function onTexturesLoaded(){
        if (--pendingTextures > 0) return;
        _B.Tools.Log("Texture Load delay:  " + ((_B.Tools.Now - texLoadStart) / 1000).toFixed(2) + " secs");
        if (_sceneTransitionName) QI.SceneTransition.perform(_sceneTransitionName, waitingMeshes, _overriddenMillis, _overriddenSound, _options);
        else {
            for (var i = 0, len = waitingMeshes.length; i < len; i++) {
                if (!waitingMeshes[i].initComplete) continue;
                if (typeof waitingMeshes[i].grandEntrance == "function") waitingMeshes[i].grandEntrance();
                else makeVisible(waitingMeshes[i]);
            }
        }
        waitingMeshes = [];
        _sceneTransitionName = null;
        matLoaded = true;
    }

    // QI.Mesh has similar method, using this to not require QI
    function makeVisible(mesh){
        var children = mesh.getChildMeshes();
        mesh.isVisible = true;
        for (var i = 0, len = children.length; i < len; i++) {
            children[i].isVisible = true;
        }
    }

    var aheadQueued = false;
    function matReadAhead(materialsRootDir) {
        if (aheadQueued) return;
        var txBuffer;
        var fName;

        aheadQueued = true;
    }
    power.matReadAhead = matReadAhead;

    var matLoaded = false;
    function defineMaterials(scene, materialsRootDir) {
        if (!materialsRootDir) { materialsRootDir = "./"; }
        if (materialsRootDir.lastIndexOf("/") + 1  !== materialsRootDir.length) { materialsRootDir  += "/"; }
        if (typeof(QI) !== "undefined") QI.TimelineControl.initialize(scene);
        if (typeof(TOWER_OF_BABEL) !== "undefined") TOWER_OF_BABEL.Preloader.SCENE = scene;
        var loadStart = _B.Tools.Now;
        matReadAhead(materialsRootDir);
        var material;
        var texture;
        var txBuffer;

        material = scene.getMaterialByID("power.Material.001");
        if (!material){
            material = new _B.StandardMaterial("power.Material.001", scene);
            material.ambientColor  = new _B.Color3(.8,.8,.8);
            material.diffuseColor  = new _B.Color3(.64,.64,.64);
            material.emissiveColor = new _B.Color3(0,0,0);
            material.specularColor = new _B.Color3(.5,.5,.5);
            material.specularPower = 50;
            material.alpha =  1;
            material.backFaceCulling = true;
            material.checkReadyOnlyOnce = false;
            material.maxSimultaneousLights = 4;
        } else material.markDirty();

        material = scene.getMaterialByID("power.Material.002");
        if (!material){
            material = new _B.StandardMaterial("power.Material.002", scene);
            material.ambientColor  = new _B.Color3(.0802,.0802,.0802);
            material.diffuseColor  = new _B.Color3(.0241,.0241,.0241);
            material.emissiveColor = new _B.Color3(0,0,0);
            material.specularColor = new _B.Color3(.0703,.0703,.0703);
            material.specularPower = 50;
            material.alpha =  1;
            material.backFaceCulling = true;
            material.checkReadyOnlyOnce = false;
            material.maxSimultaneousLights = 4;
        } else material.markDirty();

        matLoaded = pendingTextures === 0;
        if (!matLoaded) texLoadStart = _B.Tools.Now;
        _B.Tools.Log("power.defineMaterials completed:  " + ((_B.Tools.Now - loadStart) / 1000).toFixed(2) + " secs");
    }
    power.defineMaterials = defineMaterials;

    var powerShelf = (function (_super) {
        __extends(powerShelf, _super);
        function powerShelf(name, scene, materialsRootDir, source) {
            _super.call(this, name, scene, null, source, true);

            if (!materialsRootDir) { materialsRootDir = "./"; }
            defineMaterials(scene, materialsRootDir); //embedded version check
            var cloning = source && source !== null;
            var load = _B.Tools.Now;
            var geo = 0;
            var shape = 0;
            this.position.x  = 0;
            this.position.y  = 0;
            this.position.z  = 0;
            this.rotation.x  = 0;
            this.rotation.y  = 0;
            this.rotation.z  = 0;
            this.scaling.x   = 1;
            this.scaling.y   = 1;
            this.scaling.z   = 1;
            this.psuHole = cloning ? child_psuHole(scene, this, source.psuHole) : child_psuHole(scene, this);
            this.psu = cloning ? child_psu(scene, this, source.psu) : child_psu(scene, this);
            this.rmcHole = cloning ? child_rmcHole(scene, this, source.rmcHole) : child_rmcHole(scene, this);
            this.rmc = cloning ? child_rmc(scene, this, source.rmc) : child_rmc(scene, this);

            this.id = this.name;
            this.billboardMode  = 0;
            this.isVisible  = false; //always false; evaluated again at bottom
            this.setEnabled(true);
            this.checkCollisions = false;
            this.receiveShadows  = false;
            this.castShadows  = false;
            this.initComplete = false;
            if (!cloning){
                geo = _B.Tools.Now;
                this.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([
                    268,-50,-1,228,50,-1,228,-50,-1,268,-50,-400,268,50,-1,228,-50,-400,268,50,-400,218,-50,-1,178,50,-1,178,-50,-1,218,-50,-400,218,50,-1,178,-50,-400,218,50,-400,168,-50,-1,128,50,-1,128,-50,-1
                    ,168,-50,-400,168,50,-1,128,-50,-400,168,50,-400,157.8176,50,-400,118,-50,-1,78,50,-1,78,-50,-1,118,44.6546,-400,118,50,-400,118,50,-1,78,-50,-400,68,-50,-1,28,50,-1,28,-50,-1,68,37.9422,-400,68,50,-400
                    ,68,50,-1,28,-50,-400,-182,-50,-1,-222,50,-1,-222,-50,-1,-182,-50,-400,-182,-43.3646,-400,-222,-50,-400,-209.8485,-50,-400,-182,50,-400,-182,50,-1,18,-50,-1,-22,50,-1,-22,-50,-1,18,-50,-400,18,31.2298,-400,-22,-50,-400
                    ,18,50,-400,18,50,-1,-32,-50,-1,-72,50,-1,-72,-50,-1,-32,-50,-400,-32,50,-1,-72,-50,-400,-32,50,-400,-82,-50,-1,-122,50,-1,-122,-50,-1,-82,-50,-400,-82,50,-1,-122,-50,-400,-82,50,-400,-132,-50,-1
                    ,-172,50,-1,-172,-50,-1,-132,-50,-400,-132,50,-1,-172,-50,-400,-132,50,-400,-251,-64,-101,-276,64,-101,-276,-64,-101,-251,-64,-400,-251,-59.8051,-400,-276,-64,-400,-251,64,-400,-251,64,-101,277,-66,-400,-277,-66,400,277,-66,400
                    ,-277,66,400,277,66,-400,277,66,400,-277,66,-400,-277,-66,-400,-222,50,-400,-276,64,-400,-172,50,-400,-172,-40.9819,-400,-122,50,-400,-72,50,-400,28,50,-400,-22,50,-400,118,-50,-400,28,32.5723,-400,78,50,-400,78,39.2847,-400
                    ,128,50,-400,128,45.9971,-400,178,50,-400,178,-39.3578,-400,228,50,-400,228,30.339,-400,68,-50,-400
                ]),
                false);

                var _i;//indices & affected indices for shapekeys
                _i = new Uint32Array([0,1,2,3,4,0,5,0,2,6,1,4,7,8,9,10,11,7,12,7,9,13,8,11,14,15,16,17,18,14,19,14,16,20,21,18,22,23,24,25,26,27,28,22,24,26,23,27,29,30
                ,31,32,33,34,35,29,31,33,30,34,36,37,38,39,40,36,41,42,38,43,37,44,45,46,47,48,49,45,50,45,47,51,46,52,53,54,55,56,57,53,58,53,55,59,54,57,60,61,62,63
                ,64,60,65,60,62,66,61,64,67,68,69,70,71,67,72,67,69,73,68,71,74,75,76,77,78,74,79,74,76,80,75,81,82,83,84,85,86,87,87,82,84,88,83,89,84,85,87,80,78,90
                ,82,77,89,76,91,79,68,92,93,86,73,94,62,94,65,66,95,86,96,33,86,55,95,58,47,97,50,82,98,28,38,90,41,30,96,99,23,100,101,15,102,103,104,86,20,8,104,105,13,106
                ,86,1,106,107,0,4,1,3,6,4,5,3,0,6,106,1,7,11,8,10,13,11,12,10,7,13,104,8,14,18,15,17,20,18,19,17,14,15,18,21,21,102,15,22,27,23,27,22,25,98
                ,25,22,28,98,22,26,100,23,29,34,30,34,29,32,108,32,29,35,108,29,33,96,30,36,44,37,44,36,40,40,43,44,36,38,42,42,39,36,43,90,37,45,52,46,52,45,49,49,51,52
                ,50,48,45,51,97,46,53,57,54,56,59,57,58,56,53,59,95,54,60,64,61,63,66,64,65,63,60,66,94,61,67,71,68,70,73,71,72,70,67,73,92,68,74,81,75,81,74,78,78,80
                ,81,79,77,74,80,91,75,82,89,83,85,88,86,87,86,82,88,85,83,84,83,85,88,89,79,88,79,91,92,73,80,40,93,43,43,93,92,86,88,80,88,91,80,43,92,80,90,43,80,78
                ,42,41,73,86,80,78,41,90,82,78,77,77,79,89,76,75,91,93,72,69,69,68,93,73,70,65,94,66,86,73,65,94,62,61,94,66,63,58,95,59,86,66,58,95,21,86,102,59,56,50
                ,59,50,97,25,103,26,26,103,102,86,59,97,51,49,99,86,97,51,26,102,86,32,101,33,100,26,86,51,99,96,33,101,100,86,51,96,33,100,86,55,54,95,47,46,97,48,50,82,58,63
                ,78,50,78,82,65,70,78,56,58,78,72,93,40,63,65,78,72,40,39,39,42,78,82,86,6,82,6,3,39,78,72,70,72,78,82,3,5,5,107,10,107,13,10,56,78,50,99,49,35,35
                ,49,48,82,5,10,12,105,17,82,10,12,35,48,82,101,32,28,108,35,82,82,12,17,19,103,25,82,17,19,28,32,108,19,25,98,28,108,82,82,19,98,38,37,90,99,35,31,31,30,99
                ,101,28,24,24,23,101,103,19,16,16,15,103,20,17,105,104,13,86,20,105,104,86,21,20,105,12,9,9,8,105,13,107,106,106,6,86,107,5,2,2,1,107]);
                this.setIndices(_i);

                this.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([
                    -.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.3015,-.3015,-.9045,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.3015,-.3015,-.9045,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773
                    ,-.3015,.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.3015,-.3015,-.9045,0,-.7071,-.7071,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.7071,0,-.7071,-.3015,-.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.7071,0,-.7071,-.3015,-.3015,-.9045
                    ,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.7071,0,-.7071,.3015,.3015,-.9045,0,.7071,-.7071,-.3015,-.3015,-.9045,-.5773,-.5773,-.5773,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.7071,0,-.7071,.3015,.3015,-.9045
                    ,-.3015,-.3015,-.9045,-.5773,-.5773,-.5773,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.3015,-.3015,-.9045,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.3015,-.3015,-.9045,-.5773,.5773,-.5773
                    ,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.5773,-.5773,-.5773,.3015,.3015,-.9045,-.3015,-.3015,-.9045,-.5773,.5773,-.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773,-.3015,.3015,-.9045,-.7071,0,-.7071,.3015,.3015,-.9045,-.3015,-.3015,-.9045,-.5773,-.5773,-.5773,.5773,-.5773,-.5773,-.5773,-.5773,.5773,.5773,-.5773,.5773
                    ,-.5773,.5773,.5773,.5773,.5773,-.5773,.5773,.5773,.5773,-.5773,.5773,-.5773,-.5773,-.5773,-.5773,.3015,-.3015,-.9045,.3015,-.3015,-.9045,.3015,-.3015,-.9045,.7071,0,-.7071,.3015,-.3015,-.9045,.3015,-.3015,-.9045,.3015,-.3015,-.9045,.3015,-.3015,-.9045,-.3015,.3015,-.9045,.7071,0,-.7071,.3015,-.3015,-.9045,.7071,0,-.7071
                    ,.3015,-.3015,-.9045,.7071,0,-.7071,.3015,-.3015,-.9045,.7071,0,-.7071,.3015,-.3015,-.9045,.7071,0,-.7071,-.3015,.3015,-.9045
                ]),
                false);

                geo = (_B.Tools.Now - geo) / 1000;
                this.setMaterialByID("power.Material.001");
                this.subMeshes = [];
                new _B.SubMesh(0, 0, 109, 0, 642, this);
                if (scene._selectionOctree) {
                    scene.createOrUpdateSelectionOctree();
                }
            }
            if (this.postConstruction) this.postConstruction();
            this.initComplete = true;
            load = (_B.Tools.Now - load) / 1000;
            _B.Tools.Log("defined mesh: " + this.name + (cloning ? " (cloned)" : "") + " completed:  " + load.toFixed(2) + ", geometry:  " + geo.toFixed(2) + ", skey:  " + shape.toFixed(2) + " secs");
            if (matLoaded && !_sceneTransitionName){
                if (typeof this.grandEntrance == "function") this.grandEntrance();
                else makeVisible(this);

            } else waitingMeshes.push(this);
        }

        powerShelf.prototype.dispose = function (doNotRecurse) {
            _super.prototype.dispose.call(this, doNotRecurse);
            if (this.skeleton) this.skeleton.dispose();
        };
        return powerShelf;
    })(BABYLON.Mesh);
    power.powerShelf = powerShelf;

    function child_psuHole(scene, parent, source){
        var ret = new BABYLON.Mesh(parent.name + ".psuHole", scene, parent, source);
        var cloning = source && source !== null;
        var load = _B.Tools.Now;
        var geo = 0;
        var shape = 0;
        ret.position.x  = -202;
        ret.position.y  = 0;
        ret.position.z  = -201;
        ret.rotation.x  = 0;
        ret.rotation.y  = 0;
        ret.rotation.z  = 0;
        ret.scaling.x   = 1;
        ret.scaling.y   = 1;
        ret.scaling.z   = 1;

        ret.id = ret.name;
        ret.billboardMode  = 0;
        ret.isVisible  = false; //always false; evaluated again at bottom
        ret.setEnabled(true);
        ret.checkCollisions = false;
        ret.receiveShadows  = false;
        ret.castShadows  = false;
        ret.initComplete = false;
        if (!cloning){
            geo = _B.Tools.Now;
            ret.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([
                -20,50,-200,-20,-50,200,-20,-50,-200,-20,50,200,20,-50,200,20,50,200,20,-50,-200,20,50,-200
            ]),
            false);

            var _i;//indices & affected indices for shapekeys
            _i = new Uint32Array([0,1,2,3,4,1,5,6,4,4,2,1,3,7,5,0,3,1,3,5,4,5,7,6,4,6,2,3,0,7]);
            ret.setIndices(_i);

            ret.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([
                -.7071,.7071,0,-.5773,-.5773,.5773,-.7071,-.7071,0,-.5773,.5773,.5773,.5773,-.5773,.5773,.5773,.5773,.5773,.7071,-.7071,0,.7071,.7071,0
            ]),
            false);

            geo = (_B.Tools.Now - geo) / 1000;
            ret.setMaterialByID("power.Material.002");
            ret.subMeshes = [];
            new _B.SubMesh(0, 0, 8, 0, 30, ret);
            if (scene._selectionOctree) {
                scene.createOrUpdateSelectionOctree();
            }
        }
        if (this.postConstruction) this.postConstruction();
        ret.initComplete = true;
        load = (_B.Tools.Now - load) / 1000;
        _B.Tools.Log("defined mesh: " + ret.name + (cloning ? " (cloned)" : "") + " completed:  " + load.toFixed(2) + ", geometry:  " + geo.toFixed(2) + ", skey:  " + shape.toFixed(2) + " secs");
        return ret;
    }

    function child_psu(scene, parent, source){
        var ret = new BABYLON.Mesh(parent.name + ".psu", scene, parent, source);
        var cloning = source && source !== null;
        var load = _B.Tools.Now;
        var geo = 0;
        var shape = 0;
        ret.position.x  = -202;
        ret.position.y  = 0;
        ret.position.z  = -201;
        ret.rotation.x  = 0;
        ret.rotation.y  = 0;
        ret.rotation.z  = 0;
        ret.scaling.x   = 1;
        ret.scaling.y   = 1;
        ret.scaling.z   = 1;

        ret.id = ret.name;
        ret.billboardMode  = 0;
        ret.isVisible  = false; //always false; evaluated again at bottom
        ret.setEnabled(true);
        ret.checkCollisions = false;
        ret.receiveShadows  = false;
        ret.castShadows  = false;
        ret.initComplete = false;
        if (!cloning){
            geo = _B.Tools.Now;
            ret.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([
                -20,50,-200,-20,-50,200,-20,-50,-200,-20,50,200,20,-50,200,20,50,200,20,-50,-200,20,50,-200
            ]),
            false);

            var _i;//indices & affected indices for shapekeys
            _i = new Uint32Array([0,1,2,3,4,1,5,6,4,7,2,6,4,2,1,3,7,5,0,3,1,3,5,4,5,7,6,7,0,2,4,6,2,3,0,7]);
            ret.setIndices(_i);

            ret.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([
                -.5773,.5773,-.5773,-.5773,-.5773,.5773,-.5773,-.5773,-.5773,-.5773,.5773,.5773,.5773,-.5773,.5773,.5773,.5773,.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773
            ]),
            false);

            geo = (_B.Tools.Now - geo) / 1000;
            ret.setMaterialByID("power.Material.002");
            ret.subMeshes = [];
            new _B.SubMesh(0, 0, 8, 0, 36, ret);
            if (scene._selectionOctree) {
                scene.createOrUpdateSelectionOctree();
            }
        }
        if (this.postConstruction) this.postConstruction();
        ret.initComplete = true;
        load = (_B.Tools.Now - load) / 1000;
        _B.Tools.Log("defined mesh: " + ret.name + (cloning ? " (cloned)" : "") + " completed:  " + load.toFixed(2) + ", geometry:  " + geo.toFixed(2) + ", skey:  " + shape.toFixed(2) + " secs");
        return ret;
    }

    function child_rmcHole(scene, parent, source){
        var ret = new BABYLON.Mesh(parent.name + ".rmcHole", scene, parent, source);
        var cloning = source && source !== null;
        var load = _B.Tools.Now;
        var geo = 0;
        var shape = 0;
        ret.position.x  = -263.5;
        ret.position.y  = 0;
        ret.position.z  = -251;
        ret.rotation.x  = 0;
        ret.rotation.y  = 0;
        ret.rotation.z  = 0;
        ret.scaling.x   = 1;
        ret.scaling.y   = 1;
        ret.scaling.z   = 1;

        ret.id = ret.name;
        ret.billboardMode  = 0;
        ret.isVisible  = false; //always false; evaluated again at bottom
        ret.setEnabled(true);
        ret.checkCollisions = false;
        ret.receiveShadows  = false;
        ret.castShadows  = false;
        ret.initComplete = false;
        if (!cloning){
            geo = _B.Tools.Now;
            ret.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([
                -12.5,64,-150,-12.5,-64,150,-12.5,-64,-150,-12.5,64,150,12.5,-64,150,12.5,64,150,12.5,-64,-150,12.5,64,-150
            ]),
            false);

            var _i;//indices & affected indices for shapekeys
            _i = new Uint32Array([0,1,2,3,4,1,5,6,4,7,2,6,4,2,1,3,7,5,0,3,1,3,5,4,5,7,6,7,0,2,4,6,2,3,0,7]);
            ret.setIndices(_i);

            ret.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([
                -.5773,.5773,-.5773,-.5773,-.5773,.5773,-.5773,-.5773,-.5773,-.5773,.5773,.5773,.5773,-.5773,.5773,.5773,.5773,.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773
            ]),
            false);

            geo = (_B.Tools.Now - geo) / 1000;
            ret.setMaterialByID("power.Material.002");
            ret.subMeshes = [];
            new _B.SubMesh(0, 0, 8, 0, 36, ret);
            if (scene._selectionOctree) {
                scene.createOrUpdateSelectionOctree();
            }
        }
        if (this.postConstruction) this.postConstruction();
        ret.initComplete = true;
        load = (_B.Tools.Now - load) / 1000;
        _B.Tools.Log("defined mesh: " + ret.name + (cloning ? " (cloned)" : "") + " completed:  " + load.toFixed(2) + ", geometry:  " + geo.toFixed(2) + ", skey:  " + shape.toFixed(2) + " secs");
        return ret;
    }

    function child_rmc(scene, parent, source){
        var ret = new BABYLON.Mesh(parent.name + ".rmc", scene, parent, source);
        var cloning = source && source !== null;
        var load = _B.Tools.Now;
        var geo = 0;
        var shape = 0;
        ret.position.x  = 1;
        ret.position.y  = 0;
        ret.position.z  = -1;
        ret.rotation.x  = 0;
        ret.rotation.y  = 0;
        ret.rotation.z  = 0;
        ret.scaling.x   = 1;
        ret.scaling.y   = 1;
        ret.scaling.z   = 1;

        ret.id = ret.name;
        ret.billboardMode  = 0;
        ret.isVisible  = false; //always false; evaluated again at bottom
        ret.setEnabled(true);
        ret.checkCollisions = false;
        ret.receiveShadows  = false;
        ret.castShadows  = false;
        ret.initComplete = false;
        if (!cloning){
            geo = _B.Tools.Now;
            ret.setVerticesData(_B.VertexBuffer.PositionKind, new Float32Array([
                -277,64,-400,-277,-64,-100,-277,-64,-400,-277,64,-100,-252,-64,-100,-252,64,-100,-252,-64,-400,-252,64,-400
            ]),
            false);

            var _i;//indices & affected indices for shapekeys
            _i = new Uint32Array([0,1,2,3,4,1,5,6,4,7,2,6,4,2,1,3,7,5,0,3,1,3,5,4,5,7,6,7,0,2,4,6,2,3,0,7]);
            ret.setIndices(_i);

            ret.setVerticesData(_B.VertexBuffer.NormalKind, new Float32Array([
                -.5773,.5773,-.5773,-.5773,-.5773,.5773,-.5773,-.5773,-.5773,-.5773,.5773,.5773,.5773,-.5773,.5773,.5773,.5773,.5773,.5773,-.5773,-.5773,.5773,.5773,-.5773
            ]),
            false);

            geo = (_B.Tools.Now - geo) / 1000;
            ret.setMaterialByID("power.Material.002");
            ret.subMeshes = [];
            new _B.SubMesh(0, 0, 8, 0, 36, ret);
            if (scene._selectionOctree) {
                scene.createOrUpdateSelectionOctree();
            }
        }
        if (this.postConstruction) this.postConstruction();
        ret.initComplete = true;
        load = (_B.Tools.Now - load) / 1000;
        _B.Tools.Log("defined mesh: " + ret.name + (cloning ? " (cloned)" : "") + " completed:  " + load.toFixed(2) + ", geometry:  " + geo.toFixed(2) + ", skey:  " + shape.toFixed(2) + " secs");
        return ret;
    }

    function freshenShadowRenderLists(scene) {
        var renderList = [];
        for (var i = 0; i < scene.meshes.length; i++){
            if (scene.meshes[i]["castShadows"])
                renderList.push(scene.meshes[i]);
        }

        for (var i = 0; i < scene.lights.length; i++){
            if (scene.lights[i]._shadowGenerator)
                scene.lights[i]._shadowGenerator.getShadowMap().renderList = renderList;
        }
    }
    power.freshenShadowRenderLists = freshenShadowRenderLists;
})(power || (power = {}));